set(MTD_LIB mtd)

file(GLOB_RECURSE SOURCES "*.h" "*.c")
add_library(${MTD_LIB} SHARED ${SOURCES})

if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
    target_include_directories(${MTD_LIB}
        PUBLIC ${LUACLIB_SRC_DIR}
        PUBLIC ${CONAN_INCLUDE_DIRS}
        PUBLIC ${GLIB_INCLUDE_DIRS})
    target_link_libraries(${MTD_LIB}
        PUBLIC ${CONAN_LIBS_HUAWEI_SECURE_C}
        PUBLIC ${GLIB2_LIBRARIES}
        PUBLIC ${GMODULE_LIBRARIES}
        PUBLIC cutils
        PUBLIC logging)
else()
    target_include_directories(${MTD_LIB}
        PUBLIC ${GLIB_INCLUDE_DIRS})
    target_link_libraries(${MTD_LIB}
        PUBLIC ${GLIB2_LIBRARIES}
        PUBLIC libmc4lua::libmc4lua
        PUBLIC skynet::skynet
        PUBLIC liblogger::liblogger)
endif()

set_target_properties(${MTD_LIB} PROPERTIES PREFIX "")
install(TARGETS ${MTD_LIB} DESTINATION opt/bmc/luaclib)